<?php
    if (isset($_GET['address']))
        $address = $_GET['address'];
    else
        $address = '';

    $lookupPerformed = false;

    if (strlen($address) > 0) {
        require_once('Geocoder.php');
        $geocoder = new Geocoder('your key');

        try {
            $placemarks = $geocoder->lookup($address);
        }
        catch (Exception $ex) {
            echo $ex->getMessage();
            exit;
        }

        $lookupPerformed = true;
    }
?>
<html>
    <head>
        <title>Google Geocoder</title>
    </head>
    <body>
        <div>
            <form method="get" action="index.php">
                <div>
                    <input type="text"
                           name="address"
                           value="<?php echo htmlSpecialChars($address) ?>" />
                    <input type="submit" value="Lookup" />
                </div>
            </form>

            <?php if ($lookupPerformed) { ?>
                <hr />

                <h2>Geocoder Results</h2>

                <?php if (count($placemarks) > 0) { ?>
                    <dl>
                        <?php foreach ($placemarks as $placemark) { ?>
                            <dt><?php echo htmlSpecialChars($placemark) ?></dt>
                            <dd>
                                Latitude <?php echo $placemark->getPoint()->getLatitude() ?>,
                                Longitude <?php echo $placemark->getPoint()->getLongitude() ?>
                            </dd>
                        <?php } ?>
                    </dl>
                <?php } else { ?>
                    <p>
                        No matches found for <strong><?php echo htmlSpecialChars($address) ?></strong>
                    </p>
                <?php } ?>
            <?php } ?>
        </div>
    </body>
</html>